import javax.jws.Oneway;

public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Object a = new Object();
        Object b = new Object();
        Object c = new Object();
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                synchronized (a){
                    System.out.println("A");
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                    synchronized (a) {
                        System.out.println("B");
                    }
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
    }
}
